package com.xiaotu.common.exception;

import org.apache.commons.lang.StringUtils;

/**
 * @类名 SpiderException
 * @日期 2017年2月9日
 * @作者 高海军
 * @功能
 */
public class SpiderException extends RuntimeException
{
	
	private static final long serialVersionUID = 1L;
	
	private SpiderExceptionCode code;
	
	public SpiderException(SpiderExceptionCode code)
	{
		super();
		this.code = code;
	}
	
	public SpiderException(SpiderExceptionCode code, Throwable cause)
	{
		super(cause);
		this.code = code;
	}
	
	public SpiderException(SpiderExceptionCode code, String message)
	{
		super(message);
		this.code = code;
	}
	
	public SpiderExceptionCode getExceptionCode()
	{
		return this.code;
	}
	
	public SpiderException(String message)
	{
		super(message);
	}
	
	@Override
	public String getMessage()
	{
		if (StringUtils.isEmpty(super.getMessage()))
			return this.code.toString();
		return super.getMessage();
	}
}
